import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/res/gaps.dart';
import 'package:oramemo/common/routes/routes.dart';
import 'package:oramemo/common/utils/time_util.dart';
import 'package:oramemo/entity/voice_record_entity.dart';
import 'package:oramemo/generated/assets.dart';
import 'package:oramemo/pages/transcription/transcription_router.dart';

class AiTranscriptionItme extends StatelessWidget {
  final VoiceRecordRows data;
  final Function() onTap;
  final Function() onLongPress;

  const AiTranscriptionItme({
    super.key,
    required this.data, required this.onTap,
    required this.onLongPress,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      onLongPress: onLongPress,
      child: Container(
        margin: const EdgeInsets.only(bottom: 16),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(12),
          boxShadow: [
            BoxShadow(
              color: Colors.black.withOpacity(0.05),
              blurRadius: 10,
              offset: const Offset(0, 2),
            ),
          ],
        ),
        child: Padding(
          padding: const EdgeInsets.fromLTRB(15, 15, 15, 17),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              if (data.readStatus == 1)
                Container(
                  width: Get.width,
                  alignment: Alignment.centerRight,
                  child: Container(
                    width: 10,
                    height: 10,
                    decoration: BoxDecoration(
                      color: Color(0xffFF3F3F),
                      borderRadius: BorderRadius.circular(20),
                    ),
                  ),
                ),
              RichText(
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
                text: TextSpan(
                  children: <InlineSpan>[
                    const WidgetSpan(
                        child: IconX.image(
                          Assets.transcriptionSound,
                          size: 20,
                        ),
                        baseline: TextBaseline.ideographic),
                    TextSpan(
                      text: data.voiceContent ?? '',
                      style: const TextStyle(color: Colors.black, fontSize: 16),
                    ),
                  ],
                ),
              ),
              Gaps.vGap10,
              Row(
                children: [
                  const Icon(CupertinoIcons.calendar,
                      size: 16, color: Color(0xFF777777)),
                  const SizedBox(width: 4),
                  Text(TimeUtils.formatDateStr(data.createTime ?? ''),
                      style: TextStyle(color: Color(0xFF777777))),
                  const SizedBox(width: 16),
                  const Icon(CupertinoIcons.time,
                      size: 16, color: Color(0xFF777777)),
                  const SizedBox(width: 4),
                  Text(
                      TimeUtils.formatDuration(
                          Duration(seconds: data.voiceDuration ?? 0)),
                      style: TextStyle(color: Color(0xFF777777))),
                ],
              ),

              Gaps.vGap12,
              // ButtonX('note', backgroundColor: Color(0xffD9D9D9),
              //   foregroundColor: Color(0xff64696F),
              //   minSize: Size(0, 0),
              //   innerPadding: EdgeInsets.fromLTRB(10, 3, 10, 2),
              //   onPressed: () {},)
              Container(
                padding: EdgeInsets.fromLTRB(10, 2, 10, 2),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(3),
                    color: Color(0xffD9D9D9)),
                child: Text(
                  'note',
                  style: TextStyle(fontSize: 10, color: Color(0xff64696F)),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
